package com.wmz.aiagent.rag;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.document.Document;
import org.springframework.ai.transformer.KeywordMetadataEnricher;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author lihechun
 * @version 1.0
 * @description: 实现自动添加元数据标注
 * @date: 2025/5/14 19:56
 */
@Component
public class MyKeywordEnricher {
    @Resource
    private ChatModel  dashscopeChatModel;

    List<Document> enrichDocuments(List<Document> documents) {
        KeywordMetadataEnricher keywordMetadataEnricher = new KeywordMetadataEnricher(this.dashscopeChatModel, 5);
        return keywordMetadataEnricher.apply(documents);
    }
}
